-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve get_asset_relative_path(...) #108
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@strarsis Please see my comments on this one.
Secondly, what is the value of $this->handler->base_url
for those scripts that were failing in your case? Can you please mention some examples?
include/minit-assets.php
Outdated
@@ -230,21 +230,17 @@ protected function get_asset_relative_path( $handle ) { | |||
return false; | |||
} | |||
|
|||
// Remove protocol reference from the local base URL | |||
$base_url = preg_replace( '/^(https?:)/i', '', $this->handler->base_url ); | |||
$arr = explode(plugins_url(), $item_url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@strarsis What about plugins and WP core files? plugins_url()
works only with assets in plugins.
include/minit-assets.php
Outdated
return false; | ||
} | ||
|
||
// Get the trailing part of the local URL | ||
$maybe_relative = array_pop( $src_parts ); | ||
$path_abs = WP_PLUGIN_DIR . $url_rel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, WP_PLUGIN_DIR
is plugin only.
@kasparsd: I modified the function to handle also theme specific URLs. |
@kasparsd: |
This PR improves the get_asset_relative_path(...) by using WordPress constants, variables and functions to make it compatible with different types of WordPress configurations and setups (notably WordPress Bedrock).